<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>上传重要文献数据</title>
    <%@ include file="/WEB-INF/include/commoncss.jsp"%>
    <script type="text/javascript"
            src="${ctx}/javascript/laydate/laydate.js"></script>
</head>
<body>

<div action="" class="form form-horizontal" id="scheduleAdd">
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span
                class="c-red">*</span>国家中文名：</label>
        <div class="formControls col-xs-8 col-sm-3">
            <input id="nation_z" name="nation_z" value="日本" class="input-text"/>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span
                class="c-red">*</span>选择类型：</label>
        <div class="formControls col-xs-8 col-sm-3">
                <span class="select-box">
                    <select class="select" id="document_type" name="document_type">
                   <option value="1">自然环境</option>
                   <option value="2">经济</option>
                   <option value="3">政治</option>
                   <option value="4">社会</option>
                   <option value="5">科技教育</option>
                   <option value="6">国际关系</option>
                   <option value="7">侨情概况</option>
                    </select>
                </span>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span
                class="c-red">*</span>上传文献：</label>
        <%--//带文本框--%>
        <div class="formControls">
        <span class="btn-upload form-group" style="margin-left: 15px;">
                <input class="input-text upload-url radius" type="text" name="uploadfile-1" id="uploadfile-1" readonly><a  class="btn btn-primary radius"><i class="Hui-iconfont">&#xe642;</i> 选择文件</a>
               <input type="file" name="file-1" class="input-file" id="uploadFiles">
        </span>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span
                class="c-red">*</span>文献来源：</label>
        <div class="formControls col-xs-8 col-sm-3">
            <input id="document_source" name="document_source" value="http://www.baidu.com" class="input-text"/>
        </div>
    </div>

    <div class="row cl">
        <button value="" type="button" class="btn btn-success radius" style="width: 20%;margin-left: 55px;background-color: #6495ED;border-color: #6495ED;" onClick="update_files()">上传</button>
    </div>
</div>
<%@ include file="/WEB-INF/include/commonjs.jsp"%>

<script>
    function update_files(){
        var nation_z=$("#nation_z").val();
        var document_type=$("#document_type").val();
        var document_source=$("#document_source").val();

        var formData=new FormData();
        formData.append("nation_z",nation_z);
        formData.append("document_type",document_type);
        formData.append("document_source",document_source);
        formData.append("document",$("#uploadFiles")[0].files[0]);
        var url="${ctx}/literatureData/uploadLiteratureData.do";
        $.ajax({
            url:url,
            type:"post",
            data: formData,
            async:false,
            xhrFields: {
                withCredentials: true
            },
            scriptCharset: 'utf-8',
            success:function (data) {
                if(data=="添加成功"){
                    layer.msg(data,{icon:1,time:2000},function(){
                        parent.location.reload(true);
                    })
                }else{
                    layer.msg(data,{icon:2,time:2000});
                }
            },
            error:function (data) {
                alert("服务器处理失败！");
            }
        })//ajax
    }
</script>
</article>
</body>

</html>